<template>
  <div>
    <p>1.获取所有图书信息</p>
    <button @click="btn">获取信息</button>
    <p>2.查询某本书的信息</p>
    <input type="text" v-model="bookname" />
    <button @click="btns">查询</button>
    <p>3.新增书籍</p>
    <input type="text" v-model="obj.bookname" />书名
    <input type="text" v-model="obj.author" />作者
    <input type="text" v-model="obj.publisher" />出版社
    <button @click="fn">添加书籍</button>
  </div>
</template>

<script>
// axios.defaults.baseURL = "http://123.57.109.30:3006";
import axios from '../user/axios'
// import axios from "axios";
export default {
  data() {
    return {
      bookname: "",
      obj: {
        bookname: "",
        author: "",
        publisher: "",
      },
    };
  },
  methods: {
    btn() {
      axios({
        method: "GET",
        url: "/api/getbooks",
      }).then((res) => console.log(res));
    },
    btns() {
      axios({
        method: "GET",
        url: "/api/getbooks",
        params: {
          bookname: this.bookname,
        },
      }).then((res) => console.log(res));
    },
    fn() {
      axios({
        url: "/api/addbook",
        method: "POST",
        data: {
          appkey: "7250d3eb-18e1-41bc-8bb2-11483665535a",
          ...this.obj,
        },
      }).then((res) => console.log(res));
    },
  },
};
</script>

<style>
</style>